<template>
    <div>
        <el-menu
                :default-active="activeIndex2"
                class="el-menu-demo"
                mode="horizontal"
                @select="handleSelect"
                background-color="#545c64"
                text-color="#fff"
                active-text-color="#ffd04b">
            <el-menu-item index="1" style="display: inline;margin-left: 150px;" @click="$router.push('/index')">Thelog</el-menu-item>

            <el-submenu index="8"   style="display:inline; float: right;margin-right: 300px;">
                <template slot="title" >
                    <el-image :src="userInfo.ima" style="width: 50px;height: 50px;border-radius: 100%;"></el-image>
                </template>
                <el-menu-item index="5-1"   @click="$router.push('/onlyone')">个人中心</el-menu-item>
                <el-menu-item index="5-2"  @click="exit">退出</el-menu-item>
            </el-submenu>

            <el-menu-item index="4" style="display:inline; float: left;margin-right: 300px;"
                          @click="$router.push('/myphote')">我的相册
            </el-menu-item>

        </el-menu>
    </div>
</template>

<script>
    export default {
        name: "myPhote",
        data() {
            return {
                activeIndex: '1',
                activeIndex2: '1',
                token:'',
                userInfo:{
                    ima:'',
                },
            };
        },
        created() {
            this.$axios.get("/api/user/main/info",{headers:{TOKEN:this.token}}).then(res=>{
                this.userInfo = res.data.data;
            })
        },
        methods: {
            handleSizeChange(val) {
                // 改变每页显示的条数
                this.PageSize=val
                // 在改变每页显示的条数时，要将页码显示到第一页
                this.currentPage=1
            },
            // 显示第几页
            handleCurrentChange(val) {
                // 改变默认的页数
                this.currentPage=val
            },
            handleSelect(key, keyPath) {
                console.log(key, keyPath);
            },
            exit() {
                //个人中心的内容在退出后 重定向到index
                if (this.$router.push !== '/index') {
                    this.$router.replace('/index');
                }
                //1.清除标记的
                localStorage.removeItem("NAME");
                localStorage.removeItem("identity");
                localStorage.removeItem("logo");
                this.$router.go(0);
                this.reload();
                //2.怎么同步呢？
                this.username = null;
                this.$message({
                    message: '退出成功！',
                    type: 'success',
                });


            },


        }
    }
</script>

<style scoped>

</style>